@oagi/oagi 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LA6CBP44.js → chunk-CNCUINOM.js} +39 -11
- package/dist/{chunk-LA6CBP44.js.map → chunk-CNCUINOM.js.map} +1 -1
- package/dist/cli.cjs +74 -37
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +11 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +60 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -4
|
@@ -2239,8 +2239,32 @@ asyncAgentRegister("tasker:software_qa")(
|
|
|
2239
2239
|
);
|
|
2240
2240
|
|
|
2241
2241
|
// src/handler.ts
|
|
2242
|
-
|
|
2243
|
-
|
|
2242
|
+
var _robot;
|
|
2243
|
+
async function getRobot() {
|
|
2244
|
+
if (!_robot) {
|
|
2245
|
+
try {
|
|
2246
|
+
_robot = (await import("robotjs")).default;
|
|
2247
|
+
} catch {
|
|
2248
|
+
throw new Error(
|
|
2249
|
+
"robotjs is not available. Install it with: npm install robotjs\nOn Linux, ensure libx11-dev and libxtst-dev are installed."
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
return _robot;
|
|
2254
|
+
}
|
|
2255
|
+
var _sharp;
|
|
2256
|
+
async function getSharp() {
|
|
2257
|
+
if (!_sharp) {
|
|
2258
|
+
try {
|
|
2259
|
+
_sharp = (await import("sharp")).default;
|
|
2260
|
+
} catch {
|
|
2261
|
+
throw new Error(
|
|
2262
|
+
"sharp is not available. Install it with: npm install sharp"
|
|
2263
|
+
);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
return _sharp;
|
|
2267
|
+
}
|
|
2244
2268
|
var sleep3 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
2245
2269
|
var toSharpKernel = (resample) => {
|
|
2246
2270
|
switch (resample) {
|
|
@@ -2299,6 +2323,8 @@ var ScreenshotMaker = class _ScreenshotMaker {
|
|
|
2299
2323
|
return arraybuffer;
|
|
2300
2324
|
}
|
|
2301
2325
|
async provide() {
|
|
2326
|
+
const robot = await getRobot();
|
|
2327
|
+
const sharp = await getSharp();
|
|
2302
2328
|
const { width, height } = robot.getScreenSize();
|
|
2303
2329
|
const screenshot = robot.screen.capture(0, 0, width, height);
|
|
2304
2330
|
const channels = 3;
|
|
@@ -2348,7 +2374,8 @@ var DefaultActionHandler = class {
|
|
|
2348
2374
|
}
|
|
2349
2375
|
}
|
|
2350
2376
|
}
|
|
2351
|
-
#denormalize(x, y) {
|
|
2377
|
+
async #denormalize(x, y) {
|
|
2378
|
+
const robot = await getRobot();
|
|
2352
2379
|
const { width, height } = robot.getScreenSize();
|
|
2353
2380
|
let px = Math.floor(x * width / 1e3);
|
|
2354
2381
|
let py = Math.floor(y * height / 1e3);
|
|
@@ -2359,12 +2386,13 @@ var DefaultActionHandler = class {
|
|
|
2359
2386
|
return { x: px, y: py };
|
|
2360
2387
|
}
|
|
2361
2388
|
async #handleOne(action) {
|
|
2389
|
+
const robot = await getRobot();
|
|
2362
2390
|
const arg = stripOuterParens(action.argument);
|
|
2363
2391
|
switch (action.type) {
|
|
2364
2392
|
case "click": {
|
|
2365
2393
|
const coords = parseCoords(arg);
|
|
2366
2394
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2367
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2395
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2368
2396
|
robot.moveMouse(p.x, p.y);
|
|
2369
2397
|
robot.mouseClick("left", false);
|
|
2370
2398
|
return;
|
|
@@ -2372,7 +2400,7 @@ var DefaultActionHandler = class {
|
|
|
2372
2400
|
case "left_double": {
|
|
2373
2401
|
const coords = parseCoords(arg);
|
|
2374
2402
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2375
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2403
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2376
2404
|
robot.moveMouse(p.x, p.y);
|
|
2377
2405
|
robot.mouseClick("left", true);
|
|
2378
2406
|
return;
|
|
@@ -2380,7 +2408,7 @@ var DefaultActionHandler = class {
|
|
|
2380
2408
|
case "left_triple": {
|
|
2381
2409
|
const coords = parseCoords(arg);
|
|
2382
2410
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2383
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2411
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2384
2412
|
robot.moveMouse(p.x, p.y);
|
|
2385
2413
|
robot.mouseClick("left", true);
|
|
2386
2414
|
robot.mouseClick("left", false);
|
|
@@ -2389,7 +2417,7 @@ var DefaultActionHandler = class {
|
|
|
2389
2417
|
case "right_single": {
|
|
2390
2418
|
const coords = parseCoords(arg);
|
|
2391
2419
|
if (!coords) throw new Error(`Invalid coords: ${arg}`);
|
|
2392
|
-
const p = this.#denormalize(coords[0], coords[1]);
|
|
2420
|
+
const p = await this.#denormalize(coords[0], coords[1]);
|
|
2393
2421
|
robot.moveMouse(p.x, p.y);
|
|
2394
2422
|
robot.mouseClick("right", false);
|
|
2395
2423
|
return;
|
|
@@ -2397,8 +2425,8 @@ var DefaultActionHandler = class {
|
|
|
2397
2425
|
case "drag": {
|
|
2398
2426
|
const coords = parseDragCoords(arg);
|
|
2399
2427
|
if (!coords) throw new Error(`Invalid drag coords: ${arg}`);
|
|
2400
|
-
const p1 = this.#denormalize(coords[0], coords[1]);
|
|
2401
|
-
const p2 = this.#denormalize(coords[2], coords[3]);
|
|
2428
|
+
const p1 = await this.#denormalize(coords[0], coords[1]);
|
|
2429
|
+
const p2 = await this.#denormalize(coords[2], coords[3]);
|
|
2402
2430
|
robot.moveMouse(p1.x, p1.y);
|
|
2403
2431
|
robot.mouseToggle("down", "left");
|
|
2404
2432
|
robot.dragMouse(p2.x, p2.y);
|
|
@@ -2434,7 +2462,7 @@ var DefaultActionHandler = class {
|
|
|
2434
2462
|
case "scroll": {
|
|
2435
2463
|
const parsed = parseScroll(arg);
|
|
2436
2464
|
if (!parsed) throw new Error(`Invalid scroll: ${arg}`);
|
|
2437
|
-
const p = this.#denormalize(parsed[0], parsed[1]);
|
|
2465
|
+
const p = await this.#denormalize(parsed[0], parsed[1]);
|
|
2438
2466
|
const direction = parsed[2];
|
|
2439
2467
|
robot.moveMouse(p.x, p.y);
|
|
2440
2468
|
const amount = direction === "up" ? this.#cfg.scrollAmount : -this.#cfg.scrollAmount;
|
|
@@ -2492,4 +2520,4 @@ export {
|
|
|
2492
2520
|
ScreenshotMaker,
|
|
2493
2521
|
DefaultActionHandler
|
|
2494
2522
|
};
|
|
2495
|
-
//# sourceMappingURL=chunk-
|
|
2523
|
+
//# sourceMappingURL=chunk-CNCUINOM.js.map
|